#ifdef	BINARYTREE_H
#define BINARYTREE_H

#include<iostream>
using namespace std;

template <class T>
struct BinTreeNode{
	T data;
	BinTreeNode<T> *leftChild,*rightChild;
	BinTreeNode() ::leftChild(NULL),rightChild(NULL){}
	BinTreeNode(T x,BinTreeNode<T> *l = NULL,BinTreeNode<T> *r= NULL)
		:data(x),leftChild(l),rightChild(r){}
};

template <class T>
class BinaryTree{
	public:
		BinaryTree():root(NULL){}
		BinaryTree(T value):RefValue(value),root(NULL){}
		BinaryTree(BinaryTree<T> &s);
		~BinaryTree {	destroy(root);}
	public:							//get the data member
		bool IsEmpty(){ return (root ==NULL)?true:false;}
		BinTreeNode<T> *Parent(BintreeNode<T> *current){
			return (root == NULL || current==NULL)?NULL:Parent(root,current);
		}
		BinTreeNode<T> *LeftChild(BinTreeNode<T>* current){
			return (current!=NULL)?current->leftChild:NULL;
		}
		BinTreeNode<T> *RightChild(BinTreeNode<T> * current){
			return (current!=NULL)? current->rightChild:NULL;
		}
		int Height(){
			return Height(root);
		}
		int Size(){
			return Size(root);
		}
		BinTreeNode<T> *getRoot()const {
			return root;
		}
	public:							//search the tree
		void preOrder( void (*visit) (BinTreeNode<T> * p)){
			preOrder(root,visit);
		}
		void inOrder( void (*visit) (BinTreeNode<T> * p)){
			inOrder(root,visit);
		}
		void postOrder( void (*visit) (BinTreeNode<T> * p)){
			postOrder(root,visit);
		}
		void levelOrder( void (*visit) (BinTreeNode<T> * p)){
			levelOrder(root,visit);
		}
		int Insert(const T item);
		BinTreeNode<T> * Find(T item)const;

	protected:
		BinTreeNode<T> *root;
		T RefValue;
	protected:
		void CreateBinTree(ifstream &in,BinTreeNode<T> * &subTree);
		bool Insert(BinTreeNode<T> *& subTree,const T& x);
		void Destroy(BinTreeNode<T> * &subTree);
		bool Find(BinTreeNode<T> *subTree,const T& x)const;
		BinTreeNode<T> * Copy(BintreeNode<T> * orignode);
		int Height(BinTreeNode<T> *root);
		int Size(BinTreeNode<T> * root);
		BinTreeNode<T> *Parent(BinTreeNode<T>* subTree,BinTreeNode<T>* current);
		BinTreeNode<T> * Find(BinTreeNode<T> * subTree,const T& x)const;
		void preOrder(BinTreeNode<T> * subTree,void (*visit)(BinTreeNode<T> * p));
		void inOrder(BinTreeNode<T> * subTree,void (*visit)(BinTreeNode<T> * p));
		void postOrder(BinTreeNode<T> * subTree,void (*visit)(BinTreeNode<T> * p));
		void levelOrder(BinTreeNode<T> * subTree,void (*visit)(BinTreeNode<T> * p));
	protected:
		friend istream& operator >>(istream &in,BinTreeNode<T>& Tree){
		}
		friend ostream& operator <<(ostream &on,BinTreeNode<T> &Tree){
		}

};
template<class T>
BinaryTree<T>::BinaryTree(BinaryTree<T> &s){

}

template<class T>
int BinaryTree<T> insert(const T item){
	
}

template<class T>
BinTreeNode<T> * BinaryTree<T> ::Find(T item)const {

}
template<class T>
void BinaryTree<T>::CreateBinTree(ifstream &in,BinTreeNode<T> * &subTree){
}
template<class T>
bool BinaryTree<T>:: Insert(BinTreeNode<T> *& subTree,const T& x){
}
template<class T>
void BinaryTree<T>:: Destroy(BinTreeNode<T> * &subTree){
}
template<class T>
bool BinaryTree<T>:: Find(BinTreeNode<T> *subTree,const T& x)const{
}
template<class T>
BinTreeNode<T> * BinaryTree<T>:: Copy(BintreeNode<T> * orignode){
}
template<class T>
int BinaryTree<T>::Height(BinTreeNode<T> *root){
}
template<class T>
int BinaryTree<T>:: Size(BinTreeNode<T> * root){
}
template<class T>
BinTreeNode<T>* BinaryTree<T>::Parent(BinTreeNode<T>* subTree,BinTreeNode<T>* current){
}
template<class T>
BinTreeNode<T>* BinaryTree<T>:: Find(BinTreeNode<T> * subTree,const T& x)const{
}
template<class T>
void BinaryTree<T>::preOrder(BinTreeNode<T> * subTree,void (*visit)(BinTreeNode<T> * p)){
}
template<class T>
void BinaryTree<T>::inOrder(BinTreeNode<T> * subTree,void (*visit)(BinTreeNode<T> * p)){
}
template<class T>
void BinaryTree<T>::postOrder(BinTreeNode<T> * subTree,void (*visit)(BinTreeNode<T> * p)){
	if(subTree == NULL)
		return ;
	postOrder(subTree->leftChild,visit);
	postOrder(subTree->rightChild,visit);
	visit(subTree);
	return ;
}
template<class T>
void BinaryTree<T>::levelOrder(BinTreeNode<T> * subTree,void (*visit)(BinTreeNode<T> * p)){
}

#endif
